module.exports = addFoodController;
addFoodController.$inject = [
    '$rootScope',
    '$scope',
    '$location',
    //'$routeParams',
    'foodService',
    '$uibModal',
    '$uibModalInstance',
    'foods',
    'refreshFood'
]
function addFoodController($rootScope,$scope, $location, FoodSvc,$modal,$uibModalInstance,foods,refreshFood){
    console.log($rootScope.merchant)
    $scope.newFood = {};
    $scope.newFood.merchant = $rootScope.merchant._id;
    $scope.cancel = function(){
        $uibModalInstance.dismiss('cancel');
        console.log("modalewrwere  close !");
    }
    $scope.ok = function(){
        var foodForm = document.querySelector('#addFoodForm');
        var formData = new FormData(foodForm);
        formData.append('merchant', $scope.newFood.merchant);
        FoodSvc.addFood(formData,function(err,data){
            foods.push(data);
            $uibModalInstance.dismiss('cancel');
            refreshFood();
        });
    }
}